<%@page import="dao.DBConnection"%>
<%@page import="java.sql.Connection"%>
<%@page import="dao.interfaces.IUserDAO"%>
<%@page import="java.util.List"%>
<%@page import="dao.DAOFactory"%>
<%@page import="model.User"%>
<%@page import="dao.DAO"%>

<%	//check database connection
	if (DBConnection.getInstance() == null) {
		out.println("<h3 style=\"color:red; text-align:center;\">Cannot connect to the database system!!!</h3>");
		out.println("<center>Please check the conection information in the \"Connection.properties\" file " +
				"located in the \"Web-INF/classes\" folder<br />" +
				"Or check if the mysql server is opened.</center");
		return;
	}

	String contextPath = request.getContextPath();
%>

<%!
	public static final String OK_STATUS = "ok";
	public static final String ERROR_STATUS = "error";
	
	public Integer getAuthenticatedUserNumbers(ServletContext application) {
		Integer authenticatedUserCount = (Integer) application.getAttribute("authenticatedUserCount");
		
		if (authenticatedUserCount == null) {
			authenticatedUserCount = 0;
		}		
		return authenticatedUserCount;
	}

	public Integer getRegisteredUserNumbers() {
		IUserDAO<User> userDAO = DAOFactory.getUserDAO();

		return userDAO.getUserNumbers();
	}
%>